// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_a;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.*;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.DisplayMetrics;
import java.io.*;

public class cls_p
{

    public cls_p()
    {
    }

    public static int a(Context context, float f)
    {
        return (int)(0.5F + f * context.getResources().getDisplayMetrics().density);
    }

    public static Bitmap a(Context context, Uri uri, int i, int j)
    {
    	Bitmap bitmap = null;
    	InputStream inputstream=null;
        if(uri != null) {
        	 
             android.graphics.BitmapFactory.Options options;
             float f;
             float f1;
             try
             {
                 inputstream = context.getContentResolver().openInputStream(uri);
             }
             catch(FileNotFoundException filenotfoundexception)
             {
                 filenotfoundexception.printStackTrace();
                 bitmap = null;
                 return  bitmap;
             }
             options = new android.graphics.BitmapFactory.Options();
             options.inJustDecodeBounds = true;
             BitmapFactory.decodeStream(inputstream, null, options);
             options.inJustDecodeBounds = false;
             try
             {
                 inputstream.close();
             }
             catch(IOException ioexception)
             {
                 ioexception.printStackTrace();
             }
             f = (float)options.outWidth / (float)i;
             f1 = (float)options.outHeight / (float)j;
             options.inSampleSize = 1;
             if(f > 1F || f1 > 1F)
             {
                  
                 if(f <= f1)
                     f = f1;
                 options.inSampleSize = (int)(f + 0.9F);
             }
             InputStream inputstream1=null;
			try {
				inputstream1 = context.getContentResolver().openInputStream(uri);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
             bitmap = BitmapFactory.decodeStream(inputstream1, null, options);
             try
             {
                 inputstream1.close();
             }
             // Misplaced declaration of an exception variable
             catch(IOException ioexception1)
             {
                 ioexception1.printStackTrace();
             }
             
        }
 
        return bitmap;
 
    }

    public static Bitmap a(Bitmap bitmap)
    {
        int i = bitmap.getWidth();
        int j = bitmap.getHeight();
        Bitmap bitmap1 = Bitmap.createBitmap(i, j, android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap1);
        Paint paint = new Paint();
        Rect rect = new Rect(0, 0, i, j);
        RectF rectf = new RectF(rect);
        paint.setAntiAlias(true);
        canvas.drawARGB(0, 0, 0, 0);
        paint.setColor(0xff424242);
        canvas.drawRoundRect(rectf, 5F, 5F, paint);
        paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN));
        canvas.drawBitmap(bitmap, rect, rect, paint);
        return bitmap1;
    }

    public static final Bitmap a(Bitmap bitmap, float f, float f1)
    {
        Matrix matrix = new Matrix();
        int i = bitmap.getWidth();
        int j = bitmap.getHeight();
        float f2 = (float)i / f;
        float f3 = (float)j / f1;
        int k;
        int l;
        Bitmap bitmap1;
        if(f2 > f3)
        {
            l = (int)f;
            k = (int)((float)j / f2);
        } else
        {
            k = (int)f1;
            l = (int)((float)i / f3);
        }
        matrix.setScale(1F, 1F);
        bitmap1 = Bitmap.createScaledBitmap(bitmap, l, k, false);
        bitmap.recycle();
        return bitmap1;
    }

    static Bitmap a(Bitmap bitmap, int i)
    {
        Matrix matrix;
        if(i == 0 || bitmap == null)
        	return bitmap;
        matrix = new Matrix();
        matrix.setRotate(i, (float)bitmap.getWidth() / 2F, (float)bitmap.getHeight() / 2F);
        Bitmap bitmap1;
        int j = bitmap.getWidth();
        int k = bitmap.getHeight();
        bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, j, k, matrix, true);
        if(bitmap == bitmap1)
        	return bitmap;
        bitmap.recycle();
        bitmap = bitmap1;
        return bitmap;
    }

    public static Bitmap a(Bitmap bitmap, int i, int j)
    {
        if(bitmap != null) {
        	int k = bitmap.getWidth();
            int l = bitmap.getHeight();
            float f = (float)i / (float)k;
            float f1 = (float)j / (float)l;
            if(f < 1F || f1 < 1F)
            {
                Matrix matrix;
                Bitmap bitmap1;
                if(f >= f1)
                    f = f1;
                matrix = new Matrix();
                matrix.postScale(f, f);
                bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, true);
                bitmap.recycle();
                bitmap = bitmap1;
            }
        }else {
        	bitmap = null;
        }
		return bitmap;
 
    }

    public static Bitmap a(Drawable drawable)
    {
        int i = drawable.getIntrinsicWidth();
        int j = drawable.getIntrinsicHeight();
        android.graphics.Bitmap.Config config;
        Bitmap bitmap;
        Canvas canvas;
        if(drawable.getOpacity() != -1)
            config = android.graphics.Bitmap.Config.ARGB_8888;
        else
            config = android.graphics.Bitmap.Config.RGB_565;
        bitmap = Bitmap.createBitmap(i, j, config);
        canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, i, j);
        drawable.draw(canvas);
        return bitmap;
    }

    public static Bitmap a(String s)
    {
        Bitmap bitmap = null;
        Bitmap bitmap1 = BitmapFactory.decodeFile(s);
        bitmap = bitmap1;

        return bitmap;

    }

    public static Bitmap a(String s, int i, int j)
    {
        Bitmap bitmap = null;
        if(s != null) {
        	 android.graphics.BitmapFactory.Options options;
             Bitmap bitmap1=null;
             Bitmap bitmap2=null;
             Bitmap bitmap3=null;
             options = new android.graphics.BitmapFactory.Options();
             options.inJustDecodeBounds = true;
             bitmap1 = BitmapFactory.decodeFile(s, options);
             options.inJustDecodeBounds = false;
             float f = (float)options.outWidth / (float)i;
             float f1 = (float)options.outHeight / (float)j;
             options.inSampleSize = 1;
             if(f > 1F || f1 > 1F)
             {
                 
                 if(f <= f1)
                     f = f1;
                 options.inSampleSize = (int)f;
             }
             bitmap3 = BitmapFactory.decodeFile(s, options);
             bitmap2 = bitmap3;
             
             bitmap = bitmap2;
        }

        return bitmap;
 
    }

    public static Drawable a(Drawable drawable, int i, int j)
    {
        int k = drawable.getIntrinsicWidth();
        int l = drawable.getIntrinsicHeight();
        Bitmap bitmap = a(drawable);
        Matrix matrix = new Matrix();
        matrix.postScale((float)i / (float)k, (float)j / (float)l);
        return new BitmapDrawable(Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, true));
    }

    public static boolean a(Bitmap bitmap, int i, File file, android.graphics.Bitmap.CompressFormat compressformat)
    {
        FileOutputStream fileoutputstream=null;
		try {
			fileoutputstream = new FileOutputStream(file);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        boolean flag = bitmap.compress(compressformat, i, fileoutputstream);

        return flag;

    }

    public static boolean a(Bitmap bitmap, int i, String s, android.graphics.Bitmap.CompressFormat compressformat)
    {
        return a(bitmap, i, new File(s), compressformat);
    }

    public static int b(Context context, float f)
    {
        return (int)(0.5F + f / context.getResources().getDisplayMetrics().density);
    }

    public static Bitmap b(Bitmap bitmap, int i, int j)
    {
        Bitmap bitmap1 = null;
        if(bitmap != null) {
        	Bitmap bitmap2;
            if(i <= 0 || j <= 0)
            {
                bitmap1 = bitmap;
                return bitmap1;
            }
            Matrix matrix = new Matrix();
            float f = (float)bitmap.getWidth() / (float)i;
            float f1 = (float)bitmap.getHeight() / (float)j;
            int k;
            int l;
            int i1;
            int j1;
            Bitmap bitmap3;
            if(f >= f1)
                f = f1;
            k = (int)(f * (float)i);
            l = (int)(f * (float)j);
            if(k > bitmap.getWidth())
                k = bitmap.getWidth();
            if(l > bitmap.getHeight())
                l = bitmap.getHeight();
            matrix.setScale(1F / f, 1F / f);
            i1 = bitmap.getWidth() - k >> 1;
            j1 = bitmap.getHeight() / 3 - l / 2;
            if(j1 < 0)
                j1 = 0;
            System.currentTimeMillis();
            bitmap3 = Bitmap.createBitmap(bitmap, i1, j1, k, l, matrix, true);
            bitmap2 = bitmap3;
    
            bitmap1 = bitmap2;
        }
 
        return bitmap1;
 
    }

    public static Bitmap b(String s, int i, int j)
    {
        Bitmap bitmap = null;
        if(s != null) {
        	android.graphics.BitmapFactory.Options options;
            Bitmap bitmap1;
            Bitmap bitmap2;
            Bitmap bitmap3;
            options = new android.graphics.BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            bitmap1 = BitmapFactory.decodeFile(s, options);
            options.inJustDecodeBounds = false;
            float f = (float)options.outWidth / (float)i;
            float f1 = (float)options.outHeight / (float)j;
            options.inSampleSize = 1;
            if(f > 1F || f1 > 1F)
            {
                
                if(f <= f1)
                    f = f1;
                options.inSampleSize = (int)(f + 0.9F);
            }
            bitmap3 = BitmapFactory.decodeFile(s, options);
            bitmap2 = bitmap3;
    
            bitmap = bitmap2;
        }
 
        return bitmap;
 
    }

    public static Bitmap c(String s, int i, int j)
    {
        Bitmap bitmap = null;
        if(s != null){
        	 Bitmap bitmap1 = BitmapFactory.decodeFile(s);
             bitmap = b(bitmap1, i, j);
             if(bitmap1 != null)
                 bitmap1.recycle();
             
        }
        return bitmap;

    }

    public static final int a = 256;
    public static final int b = 256;
    public static final float c = 1.1F;
}
